if [ -z "$BASH" ]; then
    echo "请使用 Bash 运行此脚本"
    exit 1
fi
if [ -z "$1" ]; then
    echo "错误：未提供参数"
    exit 1
fi
git fetch
git pull
mvn clean package -D skipTests -f pom.xml

rm guns-0.0.1-SNAPSHOT.jar
cp ./target/eduServer-1.0-SNAPSHOT.jar ./

if [ -z "$BASH" ]; then
    echo "请使用 Bash 运行此脚本"
    exit 1
fi

if [[ $1 =~ ^[0-9]+$ ]]; then
    containerName=${EDUSERVER_CONTAINER_NAME}_${1}
    port_inhert=$EDUSERVER_CONTAINER_PORT
    port_offset=$1
    port=$((port_inhert + port_offset))
else
    echo "错误:输入的replic不是有效的数字"
fi

# if [ "$1" = "1" ]; then
#     containerName= ${UI_SERVER_CONTAINER_NAME}_${1}
#     port= ${UI_SERVER_CONTAINER_PORT}$1
#     echo "1"
# elif [ "$1" = "2" ]; then
#     containerName=${UI_SERVER_CONTAINER_NAME}_${1}
#     port_inhert=$UI_SERVER_CONTAINER_PORT
#     port_offset=$1
#     port=$((port_inhert + port_offset))
#     echo "2"
# fi

echo $containerName;
echo $port;

echo "Docker Start..."

docker stop $containerName
docker rm $containerName
docker build -t edu_server:v0.0.1 .

docker run -it -p $port:8700 --name $containerName    edu_server:v0.0.1

docker logs -f --tail 500 $containerName